<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('房源新增页面')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-room-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">房源编号：</label>
            <div class="col-sm-8">
                <input name="roomNumber" class="form-control" type="text" placeholder="请输入(房源编号)数字">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房源类型：</label>
            <div class="col-sm-8">
                <select name="roomType" th:with="type=${@dict.getType('sys_room_type')}" class="form-control m-b">
                    <option selected hidden value="">-请选择房源类型-</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房源面积：</label>
            <div class="col-sm-8">
                <input name="roomArea" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房源位置：</label>
            <div class="col-sm-8">
                <input name="roomPosition" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">封面图</label>
            <div class="col-sm-8">
                <input name="roomImg" type="hidden">
                <div class="file-loading">
                    <input class="form-control file-upload" id="roomImg" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房源价格：</label>
            <div class="col-sm-8">
                <input name="roomPrice" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房源标题：</label>
            <div class="col-sm-8">
                <input name="roomTitle" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房源备注：</label>
            <div class="col-sm-8">
                <input name="roomNotes" class="form-control" type="text">
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: jasny-bootstrap-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/room"

    <!-- 上传之前的校验 -->
    $("#form-video-add").validate({
        rules:{
            sort:{
                digits:true,
                required:true
            },
            videoImg:{
                required:true
            }
        },
        message:{
            "roomImg":{
                remote: "没有上传"
            }
        },
        focusCleanup: true
    });

    $("#form-room-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-room-add').serialize());
        }
    }


    <!-- 图片上传服务 -->
    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true,
        showClose: false
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })
</script>
</body>
</html>